<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2024/4/19
  Time: 15:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>供应商管理系统</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="stylesheet" href="assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="assets/css/admin.css">
    <link rel="stylesheet" href="assets/css/app.css">
    <style>
        .am-selected-status {
            font-size: 13px;
            color: #999;
        }

        .am-selected {
            width: 100%;
        }
    </style>
</head>
<body data-type="generalComponents">
<header class="am-topbar am-topbar-inverse admin-header">
    <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only"
            data-am-collapse="{target: '#topbar-collapse'}"><span class="am-sr-only">导航切换</span> <span
            class="am-icon-bars"></span></button>
    <div class="am-collapse am-topbar-collapse" id="topbar-collapse">
        <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list tpl-header-list">
            <li class="am-dropdown" data-am-dropdown data-am-dropdown-toggle>
                <a class="am-dropdown-toggle tpl-header-list-link" href="javascript:;">
                    <span id="span1" class="tpl-header-list-user-nick"></span><span class="tpl-header-list-user-ico"> <img
                        src="assets/img/user01.png"></span>
                </a>
                <ul class="am-dropdown-content">
                    <li><a href="login.jsp"><span class="am-icon-power-off"></span> 退出</a></li>
                </ul>
            </li>
        </ul>
    </div>
</header>
<div class="tpl-page-container tpl-page-header-fixed">
    <div class="tpl-left-nav tpl-left-nav-hover">
        <div class="tpl-left-nav-list">
            <ul class="tpl-left-nav-menu">
                <li class="tpl-left-nav-item">
                    <a href="javascript:;" class="nav-link tpl-left-nav-link-list active">
                        <i class="am-icon-wpforms"></i>
                        <span>企业管理</span>
                        <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right tpl-left-nav-more-ico-rotate"></i>
                    </a>
                    <ul class="tpl-left-nav-sub-menu" style="display: block;">
                        <li>
                            <a href="info-certification.jsp" class="active">
                                <i class="am-icon-angle-right"></i>
                                <span>企业信息认证</span>
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="tpl-left-nav-item">
                    <a href="javascript:;" class="nav-link tpl-left-nav-link-list">
                        <i class="am-icon-table"></i>
                        <span>供应商管理</span>
                        <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right"></i>
                    </a>
                    <ul class="tpl-left-nav-sub-menu">
                        <li>
                            <a href="white-list.jsp">
                                <i class="am-icon-angle-right"></i>
                                <span>供应商白名单</span>
                            </a>
                            <a href="black-list.jsp">
                                <i class="am-icon-angle-right"></i>
                                <span>供应商黑名单</span>
                            </a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <div class="tpl-content-wrapper">
        <div class="tpl-content-page-title">
            企业认证
        </div>
        <ol class="am-breadcrumb">
            <li class="am-active"><a style="color: #999999;">企业管理</a></li>
            <li class="am-active">企业信息认证</li>
        </ol>
        <div class="tpl-portlet-components">
            <div class="portlet-title">
                <div class="caption font-green bold">
                    企业管理员认证
                </div>
                <div class="tpl-portlet-input tpl-fz-ml">
                    <div class="portlet-input input-small input-inline">
                        <div class="input-icon right">
                        </div>
                    </div>
                </div>
            </div>
            <div class="tpl-block ">
                <div class="am-g tpl-amazeui-form">
                    <div class="am-u-sm-12 am-u-md-9">
                        <form class="am-form am-form-horizontal">
                            <div class="am-form-group">
                                <label for="user-name" class="am-u-sm-3 am-form-label">登录账号</label>
                                <div class="am-u-sm-9" id="div1">
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-email" class="am-u-sm-3 am-form-label">管理员手机号码</label>
                                <div class="am-u-sm-9" id="div2">
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-phone" class="am-u-sm-3 am-form-label">管理员姓名</label>
                                <div class="am-u-sm-9" id="div3">
                                    <input id="i1" type="text" placeholder="请输入管理员姓名" name="idcard_name">
                                    <div id="divbut1"></div>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-QQ" class="am-u-sm-3 am-form-label">管理员身份证号</label>
                                <div class="am-u-sm-9" id="div4">
                                    <input type="text" placeholder="请入管理员身份证号" name="idcard_no">
                                    <div id="divbut2"></div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <div class="tpl-portlet-components">
            <div class="portlet-title">
                <div class="caption font-green bold">
                    企业信息
                </div>
                <div class="tpl-portlet-input tpl-fz-ml">
                    <div class="portlet-input input-small input-inline">
                        <div class="input-icon right">
                        </div>
                    </div>
                </div>
            </div>
            <div class="tpl-block ">
                <div class="am-g tpl-amazeui-form">
                    <div class="am-u-sm-12 am-u-md-9">
                        <form class="am-form am-form-horizontal">
                            <div class="am-form-group">
                                <label for="user-name" class="am-u-sm-3 am-form-label">企业名称</label>
                                <div class="am-u-sm-9" id="div5">
                                    <input type="text" id="user-name" placeholder="请输入企业名称" name="enterprise_name">
                                    <div id="divbut5"></div>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-weibo" class="am-u-sm-3 am-form-label">统一社会信用代码</label>
                                <div class="am-u-sm-9" id="div6">
                                    <input type="text" id="user-weibo" placeholder="请输入统一社会信用代码" name="social_uniform_code">
                                    <div id="divbut4"></div>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-weibo" class="am-u-sm-3 am-form-label">企业规模</label>
                                <div class="am-u-sm-9" id="div7">
                                    <select placeholder="请选择企业规模" data-am-selected name="scale">
                                        <option value="4">请选择企业规模</option>
                                        <option value="A">0-20人</option>
                                        <option value="B">20-50人</option>
                                        <option value="C">50-100人</option>
                                        <option value="D">100-500人</option>
                                        <option value="F">500以上</option>
                                    </select>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-email" class="am-u-sm-3 am-form-label">企业邮箱</label>
                                <div class="am-u-sm-9" id="div8">
                                    <input type="email" id="user-email" placeholder="请输入企业邮箱" name="email">
                                    <div id="divbut3"></div>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-phone" class="am-u-sm-3 am-form-label">企业电话</label>
                                <div class="am-u-sm-9" id="div9">
                                    <input type="tel" id="user-phone" placeholder="请输入企业电话" name="ephone">
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-QQ" class="am-u-sm-3 am-form-label">传真</label>
                                <div class="am-u-sm-9" id="div10">
                                    <input type="number" pattern="[0-9]*" id="user-QQ" placeholder="请输入传真" name="fax">
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-weibo" class="am-u-sm-3 am-form-label">企业注册地</label>
                                <div class="am-u-sm-9" id="div12">
                                    <input type="text" id="user-weibo" placeholder="请企业注册地" name="address">
                                </div>
                            </div>
                            <%--<div class="am-form-group">
                                <label for="user-intro" class="am-u-sm-3 am-form-label">企业注册详细地址</label>
                                <div class="am-u-sm-9" id="div12">
                                    <textarea class="" rows="5" id="user-intro" placeholder="请输入企业注册详细地址"></textarea>
                                    <small>250字以内...</small>
                                </div>
                            </div>--%>
                            <div class="am-form-group">
                                <div class="am-u-sm-9 am-u-sm-push-3" id="div13">
                                    <button type="button" class="am-btn am-btn-primary" id="b1">提 交</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/amazeui.min.js"></script>
<script src="assets/js/app.js"></script>
<script src="assets/js/jquery-1.8.3.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#span1").html(sessionStorage.getItem("account"));
        var account = sessionStorage.getItem("account");
        var password = sessionStorage.getItem("password");
        $.get("user/ajaxFindUser","account="+account+"&password="+password,function (mess) {
            eval("var info="+mess);
            $("#div1").html(info.account);
            $("#div2").html(info.phone);
            //判断这个用户是否是第一次登陆，即判断他的属性：企业名称是否为空
            if(info.enterprise_name != null){
                $("#div3").html(info.idcard_name);
                $("#div4").html(info.idcard_no);
                $("#div5").html(info.enterprise_name);
                $("#div6").html(info.social_uniform_code);
                $("#div7").html(info.scale);
                $("#div8").html(info.email);
                $("#div9").html(info.ephone);
                $("#div10").html(info.fax);
                $("#div12").html(info.address);
                $("#div13").attr("style","display:none");
                sessionStorage.setItem("enterprise_name",info.enterprise_name);
            }else{
                $("#b1").click(function () {
                    var idcard_name = $("[name=idcard_name]").val();
                    var idcard_no = $("[name=idcard_no]").val();
                    var enterprise_name = $("[name=enterprise_name]").val();
                    var social_uniform_code = $("[name=social_uniform_code]").val();
                    var scales=$("[name=scale]>option");
                    var scale="";
                    for(var i=0;i<scales.length;i++){
                        if(scales[i].selected){
                            scale=scales[i].value;
                        }
                    }

                    var email = $("[name=email]").val();
                    var ephone = $("[name=ephone]").val();
                    var fax = $("[name=fax]").val();
                    var address = $("[name=address]").val();
                    $.get("user/ajaxadd",
                        {
                            "account":account,
                            "password":password,
                            "idcard_name": idcard_name,
                            "idcard_no": idcard_no,
                            "enterprise_name": enterprise_name,
                            "social_uniform_code": social_uniform_code,
                            "scale": scale,
                            "email": email,
                            "ephone": ephone,
                            "fax": fax,
                            "address": address
                        },
                        function (mess){
                        if(JSON.parse(mess)){
                            alert("提交成功");
                            document.location.href="info-certification.jsp";
                            $("#div13").attr("style","display:none");
                        }else{
                            alert("提交失败");
                        }
                        });
                });
            }
        });
        $("[name=idcard_name]").blur(function () {
            var idcard_name = $(this).val();
            if(idcard_name.length>5){
                $("#divbut1").empty();
                $("<span style='color: blueviolet'>账号长度不能大于5</span>").appendTo("#divbut1");
                $("#div13").attr("style","display:none");
            }else{
                $("#divbut1").empty();
                $("<span style='color: #4aaa4a'>√</span>").appendTo("#divbut1");
                $("#div13").attr("style","display:block");
            }
        });


        $("[name=idcard_no]").blur(function () {
            var idcard_no = $(this).val();
            if(idcard_no.length != 18){
                $("#divbut2").empty();
                $("<span style='color: blueviolet'>身份证号18位</span>").appendTo("#divbut2");
                $("#div13").attr("style","display:none");
            }else{
                $("#divbut2").empty();
                $("<span style='color: #4aaa4a'>√</span>").appendTo("#divbut2");
                $("#div13").attr("style","display:block");
            }
        });



        $("[name=enterprise_name]").blur(function () {
            var enterprise_name = $(this).val();
            alert(enterprise_name);
            $.get("user/judeEname","enterprise_name="+enterprise_name,function (mess) {
                if(JSON.parse(mess)){
                    $("#divbut5").empty();
                    $("<span style='color: #4aaa4a'>企业名称未重复</span>").appendTo("#divbut5");
                    $("#div13").attr("style","display:block");
                }else{
                    $("#divbut5").empty();
                    $("<span style='color:red' >企业名称重复</span>").appendTo("#divbut5");
                    $("#div13").attr("style","display:none");
                }
            });
        });


        $("[name=social_uniform_code]").blur(function () {
            var social_uniform_code = $(this).val();
            $.get("user/judgeCode","social_uniform_code="+social_uniform_code,function (mess) {
                if(JSON.parse(mess)){
                    $("#divbut4").empty();
                    $("<span style='color: #4aaa4a'>信用码未重复</span>").appendTo("#divbut4");
                    $("#div13").attr("style","display:block");
                }else{

                    $("#divbut4").empty();
                    $("<span style='color:red' >信用码重复</span>").appendTo("#divbut4");
                    $("#div13").attr("style","display:none");
                }
            });
        });



        $("[name=email]").blur(function () {
            var email = $(this).val();
            var before = email.match(/(\S*)@/)[1]; //截取@前的
            var last = email.substr(email.lastIndexOf(".")); //结尾
            if(judge(before) && (last == ".com" || last==".cn")){
                $("#divbut3").empty();
                $("<span style='color: #4aaa4a'>√</span>").appendTo("#divbut3");
                $("#div13").attr("style","display:block");
            }else{
                $("#divbut3").empty();
                $("<span style='color: #8E44AD'>@字符前只可输入字母与数字，@字符后只能以.com与.cn结尾</span>").appendTo("#divbut3");
                $("#div13").attr("style","display:none");
            }

        });
    });

    function judge(str){   //判断输入的是字母和数字
        var asc;
        for (var i = 0; i < str.length; i++) {
            asc = str.charCodeAt(i);
            if (!(asc >= 65 && asc <= 90 || asc >= 97 && asc <= 122 || asc >= 48 && asc <= 57)) {
                return false;
            }
        }
        return true;
    }

</script>

</body>
</html>
